package com.mengya.start;

/**
 * @ClassName DaemonDemo
 * @Description
 * @Author xiongwei.wu
 * @Date 2022/11/15 10:48
 **/
public class DaemonDemo {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " come in " + (Thread.currentThread().isDaemon() ? "守护线程" : "用户线程"));
            while (true) {

            }
        }, "AAAAA");
        thread.setDaemon(true);
        thread.start();

        try {
            Thread.sleep(2000);
        } catch (InterruptedException exception) {
            exception.printStackTrace();
        }

        System.out.println(Thread.currentThread().getName() + "\t" + "---------task is over");
    }
}
